/*
 * Example of usage of library swTWI - software implementation of TWI bus.
 *
 * Communication to I2C i/o extender PCF8574AP located
 * on Philips I2C evaluation board model DM1016
 *
 */

#include <Wire.h>
#include <swTWI.h>

#define PCF8574A_ADDRESS	0x3F				// I/O expander on Philips evaluation board DM1016


uint8_t data = 0;


//The setup function is called once at startup of the sketch
void setup() {
	Serial.begin(9600);

	swWire.begin(7, 8);
	swWire.beginTransmission(PCF8574A_ADDRESS);
	swWire.write(0xFF);
	swWire.endTransmission();

	Serial.println(F("swTWI library test."));
	Serial.println(F(""));
	Serial.println(F("Connecting to PCF8574AP..."));
}

// The loop function is called in an endless loop
void loop() {
	swWire.requestFrom(PCF8574A_ADDRESS, 1);
	data = swWire.read();
	Serial.println(data, BIN);
	delay(200);
}
